import urllib
import urllib.request
import re
import random
import time

def catchContent(url):
    headers = {"User-Agent" : "Mozilla/5.0(Windows NT 10.0; WOW64)"}    #伪装浏览器请求头
    request = urllib.request.Request(url=url, headers=headers) #请求服务器
    response = urllib.request.urlopen(request) #服务器应答
    content = response.read().decode('gbk') #以一定的编码方式查看源码
    return content

def patternBody(content):
    pattern = re.compile('<tbody[\s\S]*</tbody>')
    body = re.findall(pattern, str(content))
    pattern = re.compile('>(.*?)<')
    stock_page = re.findall(pattern, body[0])
    

url = 'http://quote.stockstar.com/stock/ranklist_a_3_1_1.html'
catchContent(url)